package com.ymttest.database.mongo;

import java.util.ArrayList;
import java.util.List;

import com.ymt.core.tool.FormatUtil;
import com.ymt.database.MongoDBDriver;

/************************************************************************************
 * @File name :ProductBasicInfo.java
 * @Author : xujiewei
 * @Date : 2016年6月28日
 * @Copyright : 洋码头
 * 商品合库 新库
 ************************************************************************************/
public class CountryInfoWapper {
	MongoDBDriver mdd = YmtMongoDriverFactroy.getInstance_YmtProductDBdriver("CountryInfo");

	public CountryInfoWapper() {
	}
		
	public CountryInfoBean getByCountryId(int countryId) throws Exception {
	    ArrayList<String> list = mdd.selectPart("{\"CountryId\":" + countryId +"}");
	    return list.size()>0?(CountryInfoBean) FormatUtil.GSONToObject(list.get(0),CountryInfoBean.class):null;
	}
	    
	
	public List<CountryInfoBean> getAll() throws Exception{
		ArrayList<String> list = mdd.selectAll();
		
		List<CountryInfoBean> ret = new ArrayList<CountryInfoBean>();
		for (String s: list){
			ret.add((CountryInfoBean)FormatUtil.GSONToObject(s, CountryInfoBean.class));
		}
		return ret;
	}
	
	    
	   
	public static void main(String[] args) throws Exception {
		List<CountryInfoBean> aa= new CountryInfoWapper().getAll();
		int a=1;
		int c=a;
		
	}    
	    
}
